package com.esri.core.tasks.query;

import com.esri.core.internal.util.a;
import com.esri.core.internal.util.d;
import java.io.IOException;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;

/* loaded from: classes.dex */
public class OutStatistics {
    String onStatisticField;
    String outStatisticFieldName;
    Type type;

    /* loaded from: classes.dex */
    public enum Type {
        COUNT,
        SUM,
        MIN,
        MAX,
        AVG,
        STDDEV,
        VAR
    }

    public OutStatistics(Type type, String str, String str2) {
        this.type = type;
        this.onStatisticField = str;
        this.outStatisticFieldName = str2;
    }

    public Type getType() {
        return this.type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public String getOnStatisticField() {
        return this.onStatisticField;
    }

    public void setOnStatisticField(String str) {
        this.onStatisticField = str;
    }

    public String getOutStatisticFieldName() {
        return this.outStatisticFieldName;
    }

    public void setOutStatisticFieldName(String str) {
        this.outStatisticFieldName = str;
    }

    public boolean isEmpty() {
        return this.type == null && a.a(this.onStatisticField) && a.a(this.outStatisticFieldName);
    }

    public String toJson() {
        if (isEmpty()) {
            return null;
        }
        StringWriter stringWriter = new StringWriter();
        try {
            JsonGenerator a = d.a(stringWriter);
            a.writeStartObject();
            Type type = this.type;
            if (type != null) {
                a.writeStringField("statisticType", type.toString().toLowerCase());
            }
            if (!a.a(this.onStatisticField)) {
                a.writeStringField("onStatisticField", this.onStatisticField);
            }
            if (!a.a(this.outStatisticFieldName)) {
                a.writeStringField("outStatisticFieldName", this.outStatisticFieldName);
            }
            a.writeEndObject();
            a.close();
        } catch (JsonGenerationException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        return stringWriter.toString();
    }

    public int hashCode() {
        String str = this.onStatisticField;
        int hashCode = ((str == null ? 0 : str.hashCode()) + 31) * 31;
        String str2 = this.outStatisticFieldName;
        int hashCode2 = (hashCode + (str2 == null ? 0 : str2.hashCode())) * 31;
        Type type = this.type;
        return hashCode2 + (type != null ? type.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            OutStatistics outStatistics = (OutStatistics) obj;
            String str = this.onStatisticField;
            if (str == null) {
                if (outStatistics.onStatisticField != null) {
                    return false;
                }
            } else if (!str.equals(outStatistics.onStatisticField)) {
                return false;
            }
            String str2 = this.outStatisticFieldName;
            if (str2 == null) {
                if (outStatistics.outStatisticFieldName != null) {
                    return false;
                }
            } else if (!str2.equals(outStatistics.outStatisticFieldName)) {
                return false;
            }
            return this.type == outStatistics.type;
        }
        return false;
    }
}
